package com.ev.k3cloudBusiness.controller;

import com.ev.custom.domain.AlarmRuleDO;
import com.ev.framework.annotation.EvApiByToken;
import com.ev.framework.utils.R;
import com.ev.k3cloudBusiness.service.K3ReceivableService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Api(value = "/", tags = "金蝶K3Cloud应收单")
@RestController
public class K3ReceivableController {

    @Autowired
    K3ReceivableService k3ReceivableService;

    @EvApiByToken(value = "/apis/receivable/getBySourceBillNo", method = RequestMethod.GET, apiTitle = "根据源单编号验证是否被应收单引用")
    @ApiOperation("根据源单编号验证是否被应收单引用")
    public R getBySourceBillNo(@RequestParam @Param("sourceBillNo") String sourceBillNo) {
        try {
            Integer count = k3ReceivableService.getBySourceBillNo(sourceBillNo);
            Map<String, Object> resultMap = new HashMap<>();
            resultMap.put("data", count);
            return R.ok(resultMap);
        }
        catch (Exception ex) {
            return R.error(ex.getMessage());
        }
    }
}
